import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/data/counter_notifier.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data.dart';
import 'package:provider/provider.dart';

class A2PageWidget extends StatefulWidget {
  const A2PageWidget({super.key});

  @override
  State<A2PageWidget> createState() => _A2PageWidgetState();
}

class _A2PageWidgetState extends State<A2PageWidget> {
  @override
  Widget build(BuildContext context) {
    return Consumer2<CounterNotifier, ShareData>(
        builder: (ctx, counterNotifier, shareData, child) {
      return Column(
        children: [
          Center(
            child: Text("${counterNotifier.value} + ${shareData.nickname}"),
          ),
          SizedBox(
            height: 20,
          ),
          ElevatedButton(
            onPressed: () {
              print(counterNotifier.value);
              print(shareData.nickname);
            },
            child: Text("A页面:获取B页面修改的值"),
          ),
          // ElevatedButton(
          //   onPressed: () {
          //     Navigator.push(context, MaterialPageRoute(builder: (context) {
          //       return B2PageWidget();
          //     }));
          //   },
          //   child: Text("A页面:使用路由情况跳转B"),
          // ),
        ],
      );
    });
  }
}
